]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
layout: make Chrome an implementation detail of LayoutManager
authorDan Winship <danw@gnome.org>
Mon, 25 Jul 2011 13:53:19 +0000 (09:53 -0400)
committerDan Winship <danw@gnome.org>
Wed, 3 Aug 2011 13:18:30 +0000 (09:18 -0400)
Make the Chrome object be a private member of LayoutManager, and add
new LayoutManager methods to proxy to the old Chrome methods.

https://bugzilla.gnome.org/show_bug.cgi?id=655813

js/ui/layout.js
js/ui/lookingGlass.js
js/ui/main.js
js/ui/messageTray.js
js/ui/panel.js
js/ui/panelMenu.js

index b56344070a3712953f6544be81d71510e033fb12..cebfb6e0c795cc2e933d88f50d86019fbd7cfd50 100644 (file)
@@ -27,15 +27,18 @@ LayoutManager.prototype = {
         this.primaryIndex = -1;
         this._hotCorners = [];
 
+        global.screen.connect('monitors-changed', Lang.bind(this, this._monitorsChanged));
         this._updateMonitors();
+
+        this._chrome = new Chrome(this);
+        this._updateHotCorners();
     },
 
     // This is called by Main after everything else is constructed;
-    // _updateHotCorners needs access to Main.panel, which didn't exist
+    // Chrome.init() needs access to Main.overview, which didn't exist
     // yet when the LayoutManager was constructed.
     init: function() {
-        global.screen.connect('monitors-changed', Lang.bind(this, this._monitorsChanged));
-        this._updateHotCorners();
+        this._chrome.init();
     },
 
     _updateMonitors: function() {
@@ -114,7 +117,7 @@ LayoutManager.prototype = {
             let corner = new HotCorner();
             this._hotCorners.push(corner);
             corner.actor.set_position(cornerX, cornerY);
-            Main.chrome.addActor(corner.actor);
+            this._chrome.addActor(corner.actor);
         }
     },
 
@@ -159,6 +162,60 @@ LayoutManager.prototype = {
 
     get focusMonitor() {
         return this.monitors[this.focusIndex];
+    },
+
+    // addChrome:
+    // @actor: an actor to add to the chrome layer
+    // @params: (optional) additional params
+    //
+    // Adds @actor to the chrome layer and (unless %affectsInputRegion
+    // in @params is %false) extends the input region to include it.
+    // Changes in @actor's size, position, and visibility will
+    // automatically result in appropriate changes to the input
+    // region.
+    //
+    // If %affectsStruts in @params is %true (and @actor is along a
+    // screen edge), then @actor's size and position will also affect
+    // the window manager struts. Changes to @actor's visibility will
+    // NOT affect whether or not the strut is present, however.
+    //
+    // If %visibleInFullscreen in @params is %true, the actor will be
+    // visible even when a fullscreen window should be covering it.
+    addChrome: function(actor, params) {
+        this._chrome.addActor(actor, params);
+    },
+
+    // trackChrome:
+    // @actor: a descendant of the chrome to begin tracking
+    // @params: parameters describing how to track @actor
+    //
+    // Tells the chrome to track @actor, which must be a descendant
+    // of an actor added via addChrome(). This can be used to extend the
+    // struts or input region to cover specific children.
+    //
+    // @params can have any of the same values as in addChrome(),
+    // though some possibilities don't make sense (eg, trying to have
+    // a %visibleInFullscreen child of a non-%visibleInFullscreen
+    // parent). By default, @actor has the same params as its chrome
+    // ancestor.
+    trackChrome: function(actor, params) {
+        this._chrome.trackActor(actor, params);
+    },
+
+    // untrackChrome:
+    // @actor: an actor previously tracked via trackChrome()
+    //
+    // Undoes the effect of trackChrome()
+    untrackChrome: function(actor) {
+        this._chrome.untrackActor(actor);
+    },
+
+    // removeChrome:
+    // @actor: a child of the chrome layer
+    //
+    // Removes @actor from the chrome layer
+    removeChrome: function(actor) {
+        this._chrome.removeActor(actor);
     }
 };
 Signals.addSignalMethods(LayoutManager.prototype);
@@ -337,11 +394,13 @@ const defaultParams = {
 };
 
 function Chrome() {
-    this._init();
+    this._init.apply(this, arguments);
 }
 
 Chrome.prototype = {
-    _init: function() {
+    _init: function(layoutManager) {
+        this._layoutManager = layoutManager;
+
         // The group itself has zero size so it doesn't interfere with DND
         this.actor = new Shell.GenericContainer({ width: 0, height: 0 });
         Main.uiGroup.add_actor(this.actor);
@@ -352,8 +411,8 @@ Chrome.prototype = {
 
         this._trackedActors = [];
 
-        Main.layoutManager.connect('monitors-changed',
-                                   Lang.bind(this, this._relayout));
+        this._layoutManager.connect('monitors-changed',
+                                    Lang.bind(this, this._relayout));
         global.screen.connect('restacked',
                               Lang.bind(this, this._windowsRestacked));
 
@@ -361,11 +420,6 @@ Chrome.prototype = {
         global.screen.connect('notify::n-workspaces',
                               Lang.bind(this, this._queueUpdateRegions));
 
-        Main.overview.connect('showing',
-                             Lang.bind(this, this._overviewShowing));
-        Main.overview.connect('hidden',
-                             Lang.bind(this, this._overviewHidden));
-
         this._screenSaverProxy = new ScreenSaver.ScreenSaverProxy();
         this._screenSaverProxy.connect('ActiveChanged', Lang.bind(this, this._onScreenSaverActiveChanged));
         this._screenSaverProxy.GetActiveRemote(Lang.bind(this,
@@ -377,45 +431,24 @@ Chrome.prototype = {
         this._relayout();
     },
 
+    init: function() {
+        Main.overview.connect('showing',
+                             Lang.bind(this, this._overviewShowing));
+        Main.overview.connect('hidden',
+                             Lang.bind(this, this._overviewHidden));
+    },
+
     _allocated: function(actor, box, flags) {
         let children = this.actor.get_children();
         for (let i = 0; i < children.length; i++)
             children[i].allocate_preferred_size(flags);
     },
 
-    // addActor:
-    // @actor: an actor to add to the chrome layer
-    // @params: (optional) additional params
-    //
-    // Adds @actor to the chrome layer and (unless %affectsInputRegion
-    // is %false) extends the input region to include it. Changes in
-    // @actor's size, position, and visibility will automatically
-    // result in appropriate changes to the input region.
-    //
-    // If %affectsStruts is %true (and @actor is along a screen edge),
-    // then @actor's size and position will also affect the window
-    // manager struts. Changes to @actor's visibility will NOT affect
-    // whether or not the strut is present, however.
-    //
-    // If %visibleInFullscreen is %true, the actor will be visible
-    // even when a fullscreen window should be covering it.
     addActor: function(actor, params) {
         this.actor.add_actor(actor);
         this._trackActor(actor, params);
     },
 
-    // trackActor:
-    // @actor: a descendant of the chrome to begin tracking
-    // @params: parameters describing how to track @actor
-    //
-    // Tells the chrome to track @actor, which must be a descendant
-    // of an actor added via addActor(). This can be used to extend the
-    // struts or input region to cover specific children.
-    //
-    // @params can have any of the same values as in addActor(), though
-    // some possibilities don't make sense (eg, trying to have a
-    // %visibleInFullscreen child of a non-%visibleInFullscreen parent).
-    // By default, @actor has the same params as its chrome ancestor.
     trackActor: function(actor, params) {
         let ancestor = actor.get_parent();
         let index = this._findActor(ancestor);
@@ -439,18 +472,10 @@ Chrome.prototype = {
         this._trackActor(actor, params);
     },
 
-    // untrackActor:
-    // @actor: an actor previously tracked via trackActor()
-    //
-    // Undoes the effect of trackActor()
     untrackActor: function(actor) {
         this._untrackActor(actor);
     },
 
-    // removeActor:
-    // @actor: a child of the chrome layer
-    //
-    // Removes @actor from the chrome layer
     removeActor: function(actor) {
         this.actor.remove_actor(actor);
         this._untrackActor(actor);
@@ -528,8 +553,8 @@ Chrome.prototype = {
     },
 
     _relayout: function() {
-        this._monitors = Main.layoutManager.monitors;
-        this._primaryMonitor = Main.layoutManager.primaryMonitor;
+        this._monitors = this._layoutManager.monitors;
+        this._primaryMonitor = this._layoutManager.primaryMonitor;
 
         this._updateFullscreen();
         this._updateVisibility();
@@ -757,4 +782,3 @@ Chrome.prototype = {
         return false;
     }
 };
-Signals.addSignalMethods(Chrome.prototype);
index 22894a87fc2798248a4b83c8c28902bfc79799ac..65ca7ad3c774533df92e862bbb27b163593a7929 100644 (file)
@@ -752,7 +752,7 @@ LookingGlass.prototype = {
 
         // we add it to the chrome because we want it to appear to slide
         // out from underneath the panel
-        Main.chrome.addActor(this.actor);
+        Main.layoutManager.addChrome(this.actor);
 
         this._objInspector = new ObjInspector();
         Main.uiGroup.add_actor(this._objInspector.actor);
index 05f2bb8c07b0a990b7c2641eb08ce08a12bca97a..195d3cbbef0d9daa6c9660ba5b9f156487779130 100644 (file)
@@ -42,7 +42,6 @@ DEFAULT_BACKGROUND_COLOR.from_pixel(0x2266bbff);
 
 let automountManager = null;
 let autorunManager = null;
-let chrome = null;
 let panel = null;
 let hotCorners = [];
 let placesManager = null;
@@ -136,7 +135,6 @@ function start() {
     xdndHandler = new XdndHandler.XdndHandler();
     ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager();
     overview = new Overview.Overview();
-    chrome = new Layout.Chrome();
     magnifier = new Magnifier.Magnifier();
     statusIconDispatcher = new StatusIconDispatcher.StatusIconDispatcher();
     panel = new Panel.Panel();
index afea47cc1ad6bd9a0d44b9c937d19a15e0182846..00fe91f531490b2098d1e55d4c77fca97bf9e92f 100644 (file)
@@ -1279,7 +1279,7 @@ MessageTray.prototype = {
                                                               track_hover: true });
         this._summaryBoxPointer.actor.style_class = 'summary-boxpointer';
         this._summaryBoxPointer.actor.hide();
-        Main.chrome.addActor(this._summaryBoxPointer.actor, { visibleInFullscreen: true });
+        Main.layoutManager.addChrome(this._summaryBoxPointer.actor, { visibleInFullscreen: true });
 
         this._summaryBoxPointerItem = null;
         this._summaryBoxPointerContentUpdatedId = 0;
@@ -1329,8 +1329,8 @@ MessageTray.prototype = {
         this._notificationRemoved = false;
         this._reNotifyAfterHideNotification = null;
 
-        Main.chrome.addActor(this.actor, { visibleInFullscreen: true });
-        Main.chrome.trackActor(this._notificationBin);
+        Main.layoutManager.addChrome(this.actor, { visibleInFullscreen: true });
+        Main.layoutManager.trackChrome(this._notificationBin);
 
         Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._setSizePosition));
 
index 64fe4734b59fbe1df3e2fd633472b193bf017c8f..91adc4cea20765a9464f2b9de698ba27c93503e2 100644 (file)
@@ -871,7 +871,7 @@ Panel.prototype = {
         Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded));
         Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
 
-        Main.chrome.addActor(this.actor, { affectsStruts: true });
+        Main.layoutManager.addChrome(this.actor, { affectsStruts: true });
 
         Main.ctrlAltTabManager.addGroup(this.actor, _("Top Bar"), 'start-here',
                                         { sortGroup: CtrlAltTab.SortGroup.TOP });
index 4c5ccd3a2b14489b486457165dc6b5af6ffc4b34..5e9a191ead520020177a72af7bfa6022129f7815 100644 (file)
@@ -27,7 +27,7 @@ Button.prototype = {
         this.menu.actor.add_style_class_name('panel-menu');
         this.menu.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged));
         this.menu.actor.connect('key-press-event', Lang.bind(this, this._onMenuKeyPress));
-        Main.chrome.addActor(this.menu.actor);
+        Main.layoutManager.addChrome(this.menu.actor);
         this.menu.actor.hide();
     },